﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gollie.Controls.BoundFields
{
	public class BoundFieldValidFrom : BoundField
	{
		private static string defaultText = "Direct";

		protected override string FormatDataValue(object dataValue, bool encode)
		{
			if (dataValue == null)
				return defaultText;

			DateTime dt = Convert.ToDateTime(dataValue);

			if (dt <= DateTime.Today)
				return defaultText;

			if (dt.Hour == 0 && dt.Minute == 0)
				return dt.ToString("dd-MMM-yyyy");

			return dt.ToString("dd-MMM-yyyy, HH:mm");
		}
	}
}